// SCENARIO SCRIPT

// This is the special script for your entire scenario. It contains
// special encounters and code accessable from anywhere in the scenario. it also
// contains the code that initializes important special things in the
// scenario (like shops and names and descriptions of special items).

// You can create your own states, but you should give all of them numbers greater than
// or equal to 10.

beginscenarioscript;

variables;
short i, j, k, l, choice;
string dlgstr;

body;

// This is the state that is called every time the scenario is loaded,
// even when a save file in the scenario is loaded. Some things that should go here:
//    Names and descriptions of special items.
//    Names and effects of custom special abilities.
beginstate LOAD_SCEN_STATE;
	
	init_special_item(1,"Gold Box","This is a small, gold-colored box. You found it in the Goblin Cave. It belongs to Machrone in Pleasant Town, and he wants it back.");

	init_special_abil(0,"Set Cut Scene Speed",10);
	init_special_abil(1,"Party Location",11);
	
	init_quest(0,"Get Machrone's Box","Machrone in Pleasant Town wants you to retrieve his box. He believes it is in the Goblin Cave just to the northwest. It's there, but Machrone phrased his request badly. You'll see.");
	init_quest(1,"Speak to Dan","Machrone in Pleasant Town wants you to go north to Dan's Village and speak to Dan. He may know where Machrone's orb is. He doesn't tell you, but you have to talk to him anyway. You'll see.");
	init_quest(2,"Speak to Narayan","Dan in Dan's Village told you to speak to Narayan in Dan's Village about the orb belonging to Machrone (who is currently in Pleasant Town), which has vanished and may or may not be nearby.");
	init_quest(3,"Steal the Orb (Again)","Narayan in Dan's Village (who Dan sent you to) thinks that the archmage in the northeast has the orb stolen from Machrone in Pleasant Town. And I killed Mr. Boddy in the hall with the revolver.");
	init_quest(4,"Fail","You now have to go back to Machrone and tell him that you completely failed to retrieve his orb. The archmage didn't have it. It'll be okay; trust me.");
	init_quest(5,"Go to Oakland","Time to blow this popsicle stand. Head down the path to the west to the Land of the Oaks. This place sucks. Hope your next adventure is better.");
	init_quest(6,"Kidnapped Princess","The bartender in Pleasant Town Inn said that the daughter of a wealthy family has been missing for some hours. Maybe she was kidnapped. Or maybe she is making out in the woods with her boyfriend.");
	init_quest(7,"Mysterious Wizard","The bartender in Pleasant Town Inn claimed that the Mysterious Wizard in the back rooms has a quest for adventurers. That's not necessarily YOU, but it isn't necessarily NOT you, either.");
	init_quest(8,"Missing Ring","The bartender in Pleasant Town Inn informed you that a man at a nearby table lost his wedding ring. He may want your help in recovering it. He may also tell you to go away.");
break;

// This is the state that is called only once at the very beginning of 
// the scenario. Some things that should go here:
//    The stuff in shops.
//    Creating horses and boats.
beginstate START_SCEN_STATE;
	// Initialize a few shops.
	
	// Shop 0 - Ruby Skeleton in Dan's Village
	add_item_to_shop(0,205,5); // ruby
	add_item_to_shop(0,208,5); // jeweled ring
	
	// Shop 1 - Poisonous Fungus in Dan's Village
	add_item_to_shop(1,218,10); // toadstools
	
	// Shop 2 -
	add_item_to_shop(2,403,5); // teapot
	add_item_to_shop(2,405,5); // teacup
	
	// Shop 3 -
	add_item_to_shop(3,406,10); // boardgame

	// Shop 4 -
	add_item_to_shop(4,24,4); // cursed leather armor
	add_item_to_shop(4,29,3); // cursed studded armor
	add_item_to_shop(4,44,3); // cursed dagger
	add_item_to_shop(4,49,4); // cursed short sword
	add_item_to_shop(4,89,5); // cursed bow
	add_item_to_shop(4,99,5); // cursed arrows
	add_item_to_shop(4,104,5); // cursed bolts

	// Shop 5 - Ravenheart in Dan's Village
	add_item_to_shop(5,417,10); // incense

	// Shop 6 - Mot in Dan's Village
	add_item_to_shop(6,47,10); // steel dagger
	add_item_to_shop(6,52,10); // steel short sword
	add_item_to_shop(6,57,10); // steel longsword
	add_item_to_shop(6,62,10); // steel greatsword

	while (i <= 3) {
		set_char_trait(i,22,1);
		change_custom_abil_uses(i,0,1);
		change_custom_abil_uses(i,1,1);
		i = i + 1;
		}
	
	set_flag(290,0,3);
	change_coins(10);
break;

// This state is called every tick wherever the party is in the scenario.
// You can use the set_state
beginstate START_STATE;

break;

// Place your own states below. Give each a number at least 10.
beginstate 10; // cut scene speed
	change_custom_abil_uses(who_used_custom_abil(),0,1);
	
	reset_dialog();
	add_dialog_str(0,"How fast would you like the cut scenes to go?",0);
	add_dialog_choice(0,"Slow speed.");
	add_dialog_choice(1,"Normal speed.");
	add_dialog_choice(2,"Faster!");
	choice = run_dialog(1);
	if (choice == 1)
		set_flag(290,0,4);
	if (choice == 2)
		set_flag(290,0,3);
	if (choice != 3) {
		end();
		}
	
	reset_dialog();
	add_dialog_str(0,"How fast would you like the cut scenes to go?",0);
	add_dialog_choice(0,"High speed.");
	add_dialog_choice(1,"Very high speed.");
	if (run_dialog(1) == 1)
		set_flag(290,0,2);
	else
		set_flag(290,0,1);
break;

beginstate 11; // Party location, because Windows doesn't give this in the menu
	change_custom_abil_uses(who_used_custom_abil(),1,1);
	
if (is_outdoor() == 0) {
	i = 0;
	while (i <= 5) {
		if (char_ok(i)) {
			clear_buffer();
			append_string("Character number ");
			append_number(i);
			append_string(" is located at (");
			append_number(char_loc_x(i));
			append_string(",");
			append_number(char_loc_y(i));
			append_string(")");
			get_buffer_text(dlgstr);
			print_str(dlgstr);
			}
		i = i + 1;
		}
	}
else {
	clear_buffer();
	append_string("You are in section ");
	append_number(current_out_section());
	append_string(".");
	get_buffer_text(dlgstr);
	print_str(dlgstr);
	}
break;

beginstate 12;  // TPR book
	message_dialog("You start reading this book. It seems to contain advice about how to do well on the _Stupid Ass Test_ offered by the _Evil Testing Satans._ It is actually quite funny and well written, and it makes you wonder what these classes are like.","Who knew that test prep could be fun and irreverent?");
break;

beginstate 13;  // book
	reset_dialog();
	add_dialog_str(0,"The title of this book is _Cute, Cuddly Kittens as Self-Defense._ It goes on to describe how to raise the sweetest, fluffiest kittens imaginable and scatter them around the perimeter of one's home to protect it.",0);
	add_dialog_str(1,"The gist of the argument seems to be that would-be attackers will become so distracted by petting the friendly, purring kittens that they will forget to attack, and thus they can be detected and subdued with ease.",0);
	add_dialog_str(2,"There is a great deal of underlining and many marginal notes saying, _Wow!_ and _How insightful!_ and _Much cheaper than my current system!_ This explains a lot.",0);
	run_dialog(1);
break;
